package com.yitongmao.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yitongmao.yitmfruit.R;

/*
* 作者：梁伟航 on 2017/7/12 17:31
* 类的用途：
*/
public class mHomeGridViewdangjishilingAdapter extends BaseAdapter{
    private Context context;
    String[] arrayName = new String[]{"蓝莓", "芒果", "猕猴桃", "菠萝", "西柚", "榴莲","火龙果","榴莲"};
    //String[] array = new String[]{"￥54/kg", "￥54/kg", "￥54/kg", "￥54/kg", "￥54/kg", "￥54/kg", "￥54/kg", "￥54/kg"};
    int[] images = new int[]{ R.drawable.lanmei, R.drawable.mangguo,  R.drawable.mihoutao, R.drawable.boluo,R.drawable.xiyou, R.drawable.liulian, R.drawable.huolongguo,R.drawable.liulian};
    public mHomeGridViewdangjishilingAdapter(Context context) {
        this.context=context;
    }
    @Override
    public int getCount() {
        return arrayName.length;
    }
    @Override
    public Object getItem(int position) {
        return arrayName[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(context, R.layout.mhomegridviewdangjishilingitem, null);
            viewHolder.mMyGridViewTextViewTitle = (TextView) convertView.findViewById(R.id.mMyGridViewTextViewTitle);
            viewHolder.mMyGridViewImage= (ImageView) convertView.findViewById(R.id.mMyGridViewImage);
           // viewHolder.mMyGridViewTextViewBody = (TextView) convertView.findViewById(R.id.mMyGridViewTextViewBody);
            convertView.setTag(viewHolder);//绑定ViewHolder对象
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.mMyGridViewTextViewTitle.setText(arrayName[position]);
        viewHolder.mMyGridViewImage.setImageResource(images[position]);
       // viewHolder.mMyGridViewTextViewBody.setText(array[position]);
        return convertView;
    }
    class ViewHolder {
        public TextView mMyGridViewTextViewTitle;
        public ImageView mMyGridViewImage;
        //  public TextView mMyGridViewTextViewBody;
    }

}
